using System;
using System.Diagnostics;
using System.Threading;

namespace UACluster.UAClusterAdmin
{
    public class CMD
    {
        Process m_Proc;

        public CMD()
        {
        }

        public string Run(string fileName, string runArgs)
        {
            ProcessStartInfo oProcInfo;
            string m_Result;

            m_Proc = new Process();
            oProcInfo = new ProcessStartInfo();
            oProcInfo.FileName = fileName;
            oProcInfo.Arguments = runArgs;
            oProcInfo.UseShellExecute = false;
            oProcInfo.RedirectStandardOutput = true;
            
            m_Proc.StartInfo = oProcInfo;
            m_Proc.Start();

            m_Result = m_Proc.StandardOutput.ReadToEnd();
            
            m_Proc.Close();
            m_Proc.Dispose();

            return m_Result;
        }

    }
}
